

var pageCount = 1;
function classOnload(a){
    console.log(a);

//页面渲染
var Json ={
    pageIndex:a,
    pageSize:9
}
ajax.post(ajax.myUrl+"logs/logList",Json,function(result){
    console.log(result);
    response(result);
    console.log(result.dataset.userList);
    var data = result.dataset.userList;
    var tbody = document.querySelector("tbody");
    for(var i=0;i<data.length;i++){
        var newtr = document.createElement("tr");
        newtr.innerHTML=`
        <td>${data[i].logUserName}</td>
        <td>${data[i].logClazz}</td>
        <td>${data[i].createTime}</td>
        <td>${data[i].logCount}</td>
       
        `;
        tbody.appendChild(newtr)
        
    }
})   
}
//点击发布日志，弹出模态框
//获取模态框
var addReporter = document.getElementsByClassName("addReporter")[0];
//点击发布日志
var addition = document.getElementsByClassName("addition")[0];
var write = addition.getElementsByClassName("write")[0];
write.onclick = function(){
    addReporter.style.display = "block";
}


//点击发布日志模态框中的确定或取消，模态框消失
var sure = document.getElementsByClassName("sure")[0];
sure.onclick = function(){
    var inputs = document.querySelectorAll("input");
    var selects = document.querySelectorAll("select");
    console.log(selects[1].value);
    if(selects[1].value=="JAVA班"){
        classId=1;
    }else if(selects[1].value=="ui"){
        classId=2;
    }else if(selects[1].value=="python"){
        classId=4;
    }
    addReporter.style.display = "none";
    var Json2={
         logUserName:inputs[0].value,
         logClazz:classId,
         logCount:inputs[inputs.length-1].value
    }
    console.log(Json2)
    ajax.post(ajax.myUrl+"logs/addLog",Json2,function(result){})
 }
var cancel = document.getElementsByClassName("cancel")[0];
cancel.onclick = function(){
    addReporter.style.display = "none";
}

//管理员没有发布日志功能
var userrole = localStorage.getItem("userrole");
var write = document.getElementsByClassName("write")[0];
if(userrole == "管理员"){
    write.style.display = "none";
}